﻿/**
* 
* Provides utility methods for managing objects.
* 
* @author Kirill Mourzenko
*/

class com.kirillam.handy.util.ObjectUtil 
{
	
	/** 
	 * @param	o	Object in question.
	 * 
	 * @return true if the object has no properties, false otherwise.
	 */
	public static function isEmpty( o : Object ) : Boolean
	{
		for ( var i : String in o ) return false;
		return true;
	}
	
	
	/**
	 * Whether the argument is a number.
	 * 
	 * @param	o	Object in question.
	 * @return	true if it's a number, false otherwise.
	 */
	
	public static function isNumber( o : Object ) : Boolean
	{
		return typeof( o ) == "number" || o instanceof Number;
	}
	
	
	/**
	 * Whether the argument is a string.
	 * 
	 * @param	o	Object in question.
	 * @return	true if it's a string, false otherwise.
	 */
	
	public static function isString( o : Object ) : Boolean
	{
		return typeof( o ) == "string" || o instanceof String;
	}
	
	
	/**
	 * Whether the argument is a boolean.
	 * 
	 * @param	o	Object in question.
	 * @return	true if it's a boolean, false otherwise.
	 */
	
	public static function isBoolean( o : Object ) : Boolean
	{
		return typeof( o ) == "boolean" || o instanceof Boolean;
	}
	
	
	/**
	 * Whether the argument is a movieclip.
	 * 
	 * @param	o	Object in question.
	 * @return	true if it's a movieclip, false otherwise.
	 */
	
	public static function isMovieClip( o : Object ) : Boolean
	{
		return typeof( o ) == "movieclip" || o instanceof MovieClip;
	}
}